﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _htmlDeal : System.Web.UI.Page
{
    
    public List<LIB.easyDoc> listDoc = new List<LIB.easyDoc>();
    protected void Page_Load(object sender, EventArgs e)
    {
        //string test = "a.aspx.cs";
        //string result = LIB.trans.getExt(test);
        //Response.Write(result);
        //Response.End();

        if (!IsPostBack)
        {

        }
    }

    protected void btnGenCode_Click(object sender, EventArgs e)
    {
        string cont = txtCont.Text;
        dealHtml(cont);
    }

    private void dealHtml(string cont)
    {
        Regex reg = new Regex(@"(?is)"+ txtReg.Text.Trim());
        MatchCollection match = reg.Matches(cont);
        var sb = new StringBuilder();
        foreach (Match m in match)
        {
            sb.AppendFormat(txtResult.Text, m.Groups["href"].Value, m.Groups["value"].Value);
        }
        Response.Write(sb.ToString());
    }
    private void dealHtml2(string cont)
    {
        Regex reg = new Regex(@"(?is)<a[^>]*?href=(['""\s]?)(?<href>[^'""\s]*)\1[^>]*?>(?<value>.*?)</a>");
        MatchCollection match = reg.Matches(cont);
        var sb = new StringBuilder();
        foreach (Match m in match)
        {
            sb.AppendFormat("insert into fa_auth_menu(url,menu_name,icon)values('{0}','{1}','fa  fa-file');<br>", m.Groups["href"].Value, m.Groups["value"].Value);
        }
        Response.Write(sb.ToString());
    }

}